package cn.walls1717.ggkt.vod.controller;


import cn.walls1717.ggkt.model.vod.Subject;
import cn.walls1717.ggkt.result.Result;
import cn.walls1717.ggkt.vod.service.SubjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 课程科目相关接口
 * <p>
 * 这里使用了EasyExcel实现了对课程分类的导入与导出
 *
 * @author walls1717
 * @since 2022/07/14
 */
@Api(tags = "课程科目相关接口")
@RestController
@RequestMapping("/admin/vod/subject")
public class SubjectController {

    @Autowired
    private SubjectService subjectService;

    @ApiOperation("查询下一层的课程分类")
    @GetMapping("getChildSubject/{id}")
    public Result<List<Subject>> getChildSubjectById(@PathVariable Long id) {
        List<Subject> list = subjectService.getChildSubjectById(id);
        return Result.success(list);
    }

    @ApiOperation("课程分类导出")
    @GetMapping("exportData")
    public void exportData(HttpServletResponse response) {
        subjectService.exportData(response);
    }

    @ApiOperation("课程分类导入")
    @PostMapping("importData")
    public Result<?> importData(MultipartFile file) {
        subjectService.importData(file);
        return Result.success();
    }

}

